import request from '@/utils/request'
import type {
  LoginParams,
  ResApi,
  LoginApi,
  UserListParams,
  UserInfo,
  addUserParams,
} from '@/types/data'

// 封装登录接口
export function loginApi(data: LoginParams) {
  return request<ResApi<LoginApi>>({
    method: 'post',
    url: '/user/login',
    data,
  })
}

// 封装获取用户列表接口
export function getUserListApi(params: UserListParams) {
  return request<ResApi<UserInfo[]>>({
    method: 'get',
    url: '/user/index',
    params,
  })
}

// 新增用户接口
export const addUserApi = (data: addUserParams) => {
  return request({
    method: 'post',
    url: '/user/create',
    data,
  })
}

// 用户删除接口
export const delUserApi = (params: UserInfo) => {
  return request({
    method: 'delete',
    url: '/user/delete',
    params,
  })
}

// 用户更新
export const updateUserApi = (data: any) => {
  return request({
    method: 'put',
    url: '/user/update',
    data,
  })
}
